﻿@model SuperDumpService.ViewModels.FileViewModel
@using SuperDumpService.Helpers
@using SuperDumpService.Models
@using Microsoft.Extensions.Options
@inject IAuthorizationHelper AuthorizationHelper
@inject IOptions<SuperDumpSettings> Settings

@if (Model.File.Downloadable &&
(AuthorizationHelper.CheckPolicy(User, LdapCookieAuthenticationExtension.UserPolicy) ||
Settings.Value.LdapAuthenticationSettings.ViewerDownloadableFiles.Any(f => f == Model.File.FileInfo.Name) &&
AuthorizationHelper.CheckPolicy(User, LdapCookieAuthenticationExtension.ViewerPolicy))) {
<a asp-controller="Home" asp-action="DownloadFile" asp-route-bundleId="@Model.Id.BundleId" asp-route-dumpId="@Model.Id.DumpId" asp-route-filename="@Model.File.FileInfo.Name">
	@Model.File.FileInfo.Name</a>
<span class="filesize">(@SuperDumpService.Helpers.Utility.FormattedBytes(Model.File.SizeInBytes, 0))</span>
} else {
@Model.File.FileInfo.Name
<span class="filesize">(@SuperDumpService.Helpers.Utility.FormattedBytes(Model.File.SizeInBytes, 0))</span>
}